package text;

import java.awt.Component;
import java.io.File;

import javax.swing.*;
import javax.swing.filechooser.FileSystemView;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.MutableTreeNode;

public class Test extends JFrame{

	/**
	 * @param args
	 */
	static DefaultMutableTreeNode nodeC = new DefaultMutableTreeNode();
	DefaultMutableTreeNode nodeD = new DefaultMutableTreeNode();
	DefaultMutableTreeNode nodeE = new DefaultMutableTreeNode();
	DefaultMutableTreeNode nodeF = new DefaultMutableTreeNode();
	static JTree tree;
	
	static JPanel panel = null;
	
	 
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		JFrame frame = new JFrame();
		frame.setSize(400, 400);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		panel = new JPanel();
		DefaultTreeCellRenderer hehe  = new DefaultTreeCellRenderer();
		
//		hehe.getDefaultOpenIcon();
		frame.getContentPane().add(panel);
		File s = new File("E:\3pg");
	    
		File f = new File("F:\book");
		
		
		FileSystemView fv = FileSystemView.getFileSystemView();
		
		File[] root = fv.getRoots();
		for(int i =0;i<root.length;i++)
			System.out.println(root[i]);
		
		tree = new JTree(nodeC);
		tree.setCellRenderer(hehe);
		Component c= hehe.getTreeCellRendererComponent(tree, nodeC, true, true, false, 1, true);
		nodeC.add(new DefaultMutableTreeNode("haha"));
		
		DefaultMutableTreeNode child = new DefaultMutableTreeNode("gege");
		child.add(new DefaultMutableTreeNode("1"));
		nodeC.add(child);
		tree.setRootVisible(true);
//		tree.setCellRenderer(new DefaultTreeCellRenderer());
		Icon icon = fv.getSystemIcon(root[0]);
		hehe.setLeafIcon(icon);
		hehe.setClosedIcon(icon);
		hehe.setOpenIcon(icon);
		JLabel label = new JLabel(fv.getSystemIcon(root[0]));
		
		 panel.add(tree);
		 
		
	}

}
class MyTreeCellRender extends DefaultTreeCellRenderer{
	
}